<?php
include '../common.php';
$name =trim($_POST['name']);
$password = trim($_POST['password']);

if (empty($name)) {
	exit('用户名不能为空');
}
if (empty($password)) {
	exit('密码不能为空');
}

$sql  = "SELECT * FROM public_user WHERE name = '{$name}'";
$row = select($sql,$DB);
if (!$row) {
	exit('用户名不存在');
}
$password = md5($password);
if ($password != trim($row[0]['password'])) {
	exit('密码不正确');
}
setcookie("name",$name,time()+3600,"/");
header("location:../../index.php",302);